home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / rjs.lha / RJS / Transport / src / InetDatagram.C < prev    next >
C/C++ Source or Header  |  1991-06-14  |  866b  |  51 lines

  1. #include <stdio.h>
  2. #include <osfcn.h>
  3. #include <libc.h>
  4. #include <errno.h>
  5. #include <string.h>
  6. #include <netdb.h>
  7. #include <iostream.h>
  8.  
  9. #include "Transport.h"
  10. #include <RJS/Util.h>
  11.  
  12.  
  13. int RJS_InetDatagram::socket()
  14. {
  15.     RJS_InetAddress temp(RJS_InetAddress::Any,0);
  16.  
  17.     if (inuse()) close();
  18.     if (RJS_Socket::socket() && bind(temp)) {
  19.         ss_set(SS_success);
  20.         sex=Unknown;
  21.         return 1;
  22.     }
  23.  
  24.     if (!return_on_error) 
  25.         RJS_Util::crash_and_burn("InetDatagram","open",ss_message());
  26.     return 0;
  27. }
  28.  
  29. int RJS_InetDatagram::active()
  30. {
  31.     int stat=RJS_InetDatagram::socket();
  32.     sex=Active;
  33.     return stat;
  34. }
  35.  
  36. int RJS_InetDatagram::passive(const RJS_InetAddress &is)
  37. {
  38.     if (inuse()) close();
  39.     if (RJS_Socket::socket() && bind(is)) {
  40.         ss_set(SS_success);
  41.         sex=Passive;
  42.         return 1;
  43.     }
  44.     if (!return_on_error) 
  45.         RJS_Util::crash_and_burn("InetDatagram","open",ss_message());
  46.     return 0;
  47.  
  48. }
  49.  
  50.  
  51.